﻿@using EasyCourse.Model;
@using EasyFramework.Core;
@model VAssignmentInfo
@{
    Layout = null;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    ViewData["CourseId"] = pageInfo.CourseId;
    ViewData["MenuIndex"] = 10;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>作业列表</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @pageInfo.CourseName
                <br>
                <small>广州中医药大学康复治疗微课程网络学习平台</small>
            </h1>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicNav.cshtml")
    <div class="container wrap mb10">
        <div class="row">
            <div class="col-xs-9 publicLBox">
                <div class="lBox part">
                    <div class="lBox-th">
                        <h3>@Model.Entity.Title</h3>
                    </div>
                    <div class="lBox-tb">
                        <div class="zy-content">
                             <label class="control-label mb10">作业提交状态：</label>
                                        
                                            
                            <p class="mb10"> <em class="red">@Model.SubmitStatusDesc </em></p>
                            <div class="form-group">
                                <label for="exampleInputFile" class="mb10">附件下载</label>
                                <table class="table table-bordered table-hover zy-table">
                                    <thead>
                                        <tr>
                                            <th width="10%">ID</th>
                                            <th width="65%">文件名</th>
                                            <th width="15%">上传时间</th>
                                            <th width="10%">操作选项</th>
                                        </tr>
                                    </thead>
                                    <tbody> 
                                        <tr>
                                            <td>1</td>
                                            <td>@Model.Entity.Title</td>
                                            <td>@Model.Entity.CreateTime.ToTimeString()</td>
                                            <td><a href="@WebSiteDomain.ResFileDomain@Model.Entity.AttachmentUrl" target="_blank">下载</a></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            
                                <div class="form-group">
                                    
                                        <label class="control-label mb10">已选文件：</label>
                                        
                                            <input name="fileName" id="fileName" class="form-control mb10" readonly="readonly" />
                                        
                                    
                                    
                                        <label class="control-label mb10"  for="exampleInputFile">选择作业文件：</label>
                                    <p><em class="red">最大限制20M，只能上传zip或者rar格式</em></p>    
                                            <input id="file_upload" name="file_upload" type="file" class="form-control input-sm">
                                   
                                    
                                        <label class="control-label mb10">作业提交截至时间：</label>
                                        
                                    <p class="mb10">
                                    <em class="red">@Model.Entity.DeadTime.ToTimeString()</em>
                                       </p> 
                                    
                                            <a href="javascript:submitAssignment()" class="btn btn-success btn-md"><span class="glyphicon glyphicon-ok"></span> 提交 </a>
                                                                        
                                </div>
                                
                          
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-xs-3">
                @Html.Partial("~/Views/Share/PublicRBox.cshtml", ViewData)
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml");

    <script type="text/javascript" src="../Js/uploadToggle.js"></script>
        <script type="text/javascript">
        //上传文件
        var _attachmentUrl = null;
        $(function () {
            uploadToggle('@Url.Action("UpdateAssignmentFile", "Assignment")', { 'AssignmentId': '@Model.Entity.Id' }, function (file, data) {
                var json = $.parseJSON(data);
                if (json.result) {
                    _attachmentUrl = json.message; //文件保存的地址
                    $("#fileName").val(file.name);
                }
                else {
                    showTips.open(json.message);
                }
            });
            @*$("#file_upload").uploadify({
            'queueSizeLimit': 1,
            'formData': { 'AssignmentId': '@Model.Entity.Id' },
            'buttonText': '请选择上传文件',
            'swf': '../Content/uploadify/uploadify.swf',
            'uploader': '@Url.Action("UpdateAssignmentFile", "Assignment")',
            'onUploadSuccess': function (file, data, response) {
                var json = $.parseJSON(data);
                if (json.result) {
                    _attachmentUrl = json.message; //文件保存的地址
                    $("#fileName").val(file.name);
                }
                else {
                    showTips.open(json.message);
                }
            }
        });*@
        });
        //提交作业数据
        function submitAssignment() {
            if (!_attachmentUrl) {
                showTips.open("请先上传附件");
                return;
            }
            var assignmentId = $.getUrlParam("AssignmentId");
            if (!assignmentId) {
                showTips.open("页面参数错误");
                return;
            }
            var postData = { "AssignmentInfoId": assignmentId, "AttachmentUrl": _attachmentUrl };
            $.easyPost("@Url.Action("SubmitAssignment", "Assignment")", postData, function (data) {
                if (!data.result) {
                    showTips.open(data.message);
                } else {
                    showTips.open("提交成功");
                    setTimeout(function () {
                        location.reload()
                    }, 500)
                }
            });

        }

    </script>
</body>
</html>